<?php
$redis = new Redis();
$redis->connect("127.0.0.1", 6379);

$key = 'city.map';

$redis->del($key);
$rt['new set']  = $redis->hSet($key, 123, "beijing");
$rt['update'] = $redis->hSet($key, 123, "hubei");
$rt['456 string'] = $redis->hSet($key, "456", "lisi");
$rt['456 int'] = $redis->hSet($key, 456, "misi");
$data = ['52' => 'liucheng', 1 => 'zhonggong', 2=> 'shanghai', 3 => 'guangzhou', 4 => 'shenzhen'];
$rt['hmset'] = $redis->hMset($key, $data);
$rt['info'] = $redis->hGetAll($key);
var_dump($rt);


$rt1["hdel($key, 1, 2)"] = $redis->hdel($key, 1, 2);
$fields = [3, 4];
//$data["hdel($key, [3,4])"] = $redis->hdel($key, $fields); //hdel不支持数组
$rt1["hdel($key, ...[3,4])"] = $redis->hdel($key, ...$fields);

$rt1[123] = $redis->hGet($key, (string)123);

$rt1 = [
	'ttl' => $redis->ttl($key),
	'data' => $redis->hGetAll($key)
] + $rt1;

var_dump($rt1);
